import Vue from 'vue'
import App from './App.vue'
import { router, defaultTitle } from './router'
import store from './store/index'
// http
import httpPlugin from './http'
// 750屏幕
import './style/rem.less'
import './registerServiceWorker'
// vant-weapp
import Vant from 'vant'
import 'vant/lib/index.css'
// 动画
import './assets/css/animate.less'
// 初始化css
import 'normalize.css/normalize.css'
import './assets/css/common.less'
// 300
import FastClick from 'fastclick'

Vue.use(Vant)
Vue.use(httpPlugin)
Vue.config.productionTip = false

FastClick.attach(document.body)
router.beforeEach((to, from, next) => {
  // console.log('from.fullPath:', from.fullPath)
  store.commit('SET_CURRENT_ROUTE', to.fullPath)
  if (from.fullPath) {
    store.commit('SET_BEFORE_ROUTE', from.path)
  }
  // window.scrollTo(0, 0)
  next()
})
document.title = defaultTitle

window.$globalHub = new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
